package com.du.managerback.utils;

//统一返回格式
public class BaseResult {
    //返回码
    private String code;
    //返回的消息
    private String msg;
    //返回的数据
    private Object data;

    //不带参数的返回成功
    public static BaseResult success() {
        BaseResult result = new BaseResult();
        result.setCode("200");
        result.setMsg("请求成功");
        return result;
    }

    //带参数的返回成功
    public static BaseResult success(Object data) {
        BaseResult result = success();
        result.setData(data);
        return result;
    }

    //请求失败
    public static BaseResult error() {
        BaseResult baseResult = new BaseResult();
        baseResult.setCode("500");
        baseResult.setMsg("服务器报错了");
        return baseResult;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}